package com.g4.shoppingsingle.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.g4.shoppingsingle.mapper.DdCategorysInfoMapper;
import com.g4.shoppingsingle.pojo.DdCategorysInfo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * 产品类型表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-10-27
 */
@RestController
@RequestMapping("/shoppingsingle/ddCategorysInfo")
public class DdCategorysInfoController {

    @Autowired(required = false)
    private DdCategorysInfoMapper ddCategorysInfoMapper;

    @GetMapping("/{id}")
    @ApiOperation("按商品分类查询分类下的商品")
    public ModelAndView liebiao(@ApiParam(value = "产品类型id") @PathVariable Long id){
        //ModelAndView 使用这个来做页面跳转
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/liebiao");
        mv.addObject("id",id);
        return mv;
    }

    /**
     * 查询全部产品分类
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询全部产品分类")
    public List<DdCategorysInfo> list(){
        QueryWrapper<DdCategorysInfo> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("category_name","小米手机");   //  where category_name = '小米手机';
        List<DdCategorysInfo>  list = ddCategorysInfoMapper.selectList(null);  //select * from dd_categorys_info;
//        System.out.println("从数据库中查询出来的结果--："+ list);
        return list;
    }






}
